﻿namespace DatabaseDoc.Parameters
{    
    using System.Collections.Generic;
    using System.Linq;

    public class Parameter
    {
        public string Name { get; set; }

        public string Value { get; set; }

        public IEnumerable<Option> Options { get; set; }

        public bool HasValue
        {
            get
            {
                return !string.IsNullOrWhiteSpace(this.Value);
            }
        }

        public bool HasOptions
        {
            get
            {
                return this.Options != null && this.Options.Count() > 0;
            }            
        }

        public bool HasSingleOption
        {
            get
            {
                return this.HasOptions && this.Options.Count() == 1;
            }
        }

        public bool HasMultipleOptions
        {
            get
            {
                return this.HasOptions && this.Options.Count() > 1;
            }
        }

        public bool Matches(string parameterName)
        {
            if (string.IsNullOrWhiteSpace(parameterName))
            {
                return false;
            }

            var match = string.Compare(parameterName, this.Name, true) == 0;
            return match;
        }
    }
}